{php include wl_template('common/header');}
<ul class="nav nav-tabs">
	<li class="active"><a href="javascript:;">公众号信息</a></li>
</ul>
<div class="app-content">
	<div class="channel-set">
		<div class="pull-left">
			<div class="channel-title">微信公众号</div>
			<div class="channel-des">绑定微信公众号，将平台与微信公众号打通</div>
		</div>
	</div>
	<div class="app-form">
		<div class="panel panel-default">
			<form action="" class="form-horizontal form " method="post">
				<div class="panel-body">
					<div class="form-group">
						<div class="col-sm-2 control-label">公众号名称</div>
						<div class="col-sm-9">
							<div class="input-group">
								<input class="form-control" type="text" value="{$info['name']}" readonly="readonly"/>
								<a class="btn btn-primary js-clip input-group-addon" onclick="editData('公众号名称', 'name', '{$info['name']}')" href="javascript:;">修改</a>
							</div>
						</div>
					</div>
					<div class="form-group">
						<div class="col-sm-2 control-label">AppId</div>
						<div class="col-sm-9">
							<div class="input-group">
								<input class="form-control" type="text" value="{$info['key']}" readonly="readonly"/>
								<a class="btn btn-primary js-clip input-group-addon" onclick="editData('AppId', 'key', '{$info['key']}')" href="javascript:;">修改</a>
							</div>
						</div>
					</div>
					<div class="form-group">
						<div class="col-sm-2 control-label">AppSecret</div>
						<div class="col-sm-9">
							<div class="input-group">
								<input class="form-control" type="text" value="{$info['secret']}" readonly="readonly"/>
								<a class="btn btn-primary js-clip input-group-addon" onclick="editData('AppSecret', 'secret', '{$info['secret']}')" href="javascript:;">修改</a>
							</div>
						</div>
					</div>
					<div class="form-group-title">消息推送</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">URL(服务器地址)</label>
						<div class="col-sm-9">
							<div class="input-group">
								<input type="text" value="{$info['serviceUrl']}" class="form-control" readonly="readonly">
								<a class="btn btn-primary js-clip input-group-addon" data-url="{$info['serviceUrl']}" href="javascript:;" >复制链接</a>
							</div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">Token(令牌)</label>
						<div class="col-sm-9">
							<div class="input-group">
								<input type="text" value="{$info['token']}" class="form-control" readonly="readonly">
								<a class="btn btn-primary js-clip input-group-addon" onclick="tokenGen()" href="javascript:;">生成新的</a>
								<a class="btn btn-primary js-clip input-group-addon" data-url="{$info['token']}" href="javascript:;">复制内容</a>
							</div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">EncodingAESKey(消息加解密密钥)</label>
						<div class="col-sm-9">
							<div class="input-group">
								<input type="text" value="{$info['encodingaeskey']}" class="form-control" readonly="readonly">
								<a class="btn btn-primary js-clip input-group-addon" onclick="EncodingAESKeyGen()" href="javascript:;">生成新的</a>
								<a class="btn btn-primary js-clip input-group-addon" data-url="{$info['encodingaeskey']}" href="javascript:;">复制内容</a>
							</div>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<input type="hidden" id="myModalKey" />
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="myModalTitle"></h4>
				</div>
				<div class="modal-body">
					<div class="form-group">
						<input type="text" id="myModalInput" class="form-control" placeholder="请填写修改的内容" />
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-primary" onclick="postData($('#myModalKey').val(), $('#myModalInput').val())">确定</button>
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
	function editData(title, key, value) {
		$('#myModalTitle').html('修改'+ title)
		$('#myModalKey').val(key)
		$('#myModalInput').val(value)
		$('#myModal').modal('show')
	}
	function tokenGen() {
		var letters = 'abcdefghijklmnopqrstuvwxyz0123456789';
		var token = '';
		for(var i = 0; i < 32; i++) {
			var j = parseInt(Math.random() * (31 + 1));
			token += letters[j];
		}
		postData('token', token);
	}
	function EncodingAESKeyGen() {
		var letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
		var token = '';
		for(var i = 0; i < 43; i++) {
			var j = parseInt(Math.random() * 61 + 1);
			token += letters[j];
		}
		postData('encodingaeskey', token);
	}
	function postData(type, value) {
		$.post("{php echo url('account/post/base', ['uniacid' => $_W['uniacid']]);}" + "&type=" + type + "&request_data=" + value, function (data) {
			if (data.message.errno == 0) {
				tip.alert(data.message.message, function () {
					location.reload();
				});
			} else {
				tip.alert(data.message.message);
			}
		},'json');
	}
</script>
{php include wl_template('common/footer');}